package com.bdqn.config;

import com.bdqn.web.AuthorizationInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * InterceptorConfig
 *
 * @author
 * @since
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    private String[] pathPatterns = {"/**"}; // 拦截路径规则
    private String[] excludePathPatterns = {"/", "/login", "/doLogin", "/css/**", "/fonts/**", "/images/**", "/js/**", "/localcss/**", "/localjs/**"}; // 排除路径规则

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthorizationInterceptor()) // 注册拦截器
                .addPathPatterns(pathPatterns) // 添加路径规则
                .excludePathPatterns(excludePathPatterns); //添加排除路径规则
    }
}
